/*
 * 描述
 * Created by: litangyu
 * 包含类名列表
 * 版本信息，版本号 v1.0
 * 创建日期 16/8/31
 * 版权声明
*/
package com.foton.logistic.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.foton.logistic.R;
import com.foton.logistic.adapter.AbnormalAdapter;
import com.foton.logistic.adapter.ImageGridAdapter;
import com.foton.logistic.base.BaseActivity;
import com.foton.logistic.base.BaseApplication;
import com.foton.logistic.daemon.IntentWrapper;
import com.foton.logistic.listener.IOnAbnormalListener;
import com.foton.logistic.listener.IOnResultListener;
import com.foton.logistic.listener.IOnTryClickListener;
import com.foton.logistic.model.GPSEntity;
import com.foton.logistic.model.order.AbnormalEntity;
import com.foton.logistic.model.order.LocalOrderEntity;
import com.foton.logistic.model.order.LocationEntity;
import com.foton.logistic.model.order.OrderDetailResult;
import com.foton.logistic.model.order.OrderEntity;
import com.foton.logistic.model.order.OrderListResult;
import com.foton.logistic.model.order.StatusEntity;
import com.foton.logistic.service.LocationService;
import com.foton.logistic.task.DispatchTask;
import com.foton.logistic.task.ShowDialogTask;
import com.foton.logistic.task.ShowLoadTask;
import com.foton.logistic.task.TaskConstant;
import com.foton.logistic.util.BaseConstant;
import com.foton.logistic.util.BroadcastUtil;
import com.foton.logistic.util.LocationUtil;
import com.foton.logistic.util.OptionUtil;
import com.foton.logistic.util.OrderUtil;
import com.foton.logistic.util.SharedUtil;
import com.foton.logistic.util.TimeUtil;
import com.foton.logistic.util.net.HttpUtil;
import com.foton.logistic.util.tool.DataCleanManager;
import com.foton.logistic.util.tool.DensityUtil;
import com.foton.logistic.util.tool.FileUtil;
import com.foton.logistic.util.tool.LogUtil;
import com.foton.logistic.util.tool.StringUtil;
import com.foton.logistic.view.MyGridView;
import com.foton.logistic.view.MyScrollview;
import com.foton.logistic.view.chooseimages.ImagesPreviewUtil;
import com.foton.logistic.view.ultimate.UltimateRecyclerView;
import com.foton.logistic.view.ultimate.VerticalSwipeRefreshLayout;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * 描述
 * 订单详情
 * Created by: litangyu<br/>
 * Created on: 16/8/31 上午10:10
 */
public class OrderDetailActivity extends BaseActivity {
    @InjectView(R.id.ft_ui_order_detail_refresh_layout)
    VerticalSwipeRefreshLayout refreshLayout;
    @InjectView(R.id.ft_ui_order_detail_scrollview)
    MyScrollview detailMyScrollview;
    @InjectView(R.id.ft_ui_order_detail_tip_layout)
    LinearLayout detailTipLayout;
    @InjectView(R.id.ft_ui_order_detail_order_id)
    TextView detailOrderId;
    @InjectView(R.id.ft_ui_order_detail_status)
    TextView detailStatus;
    @InjectView(R.id.ft_ui_order_detail_start_address)
    TextView detailStartAddress;
    @InjectView(R.id.ft_ui_order_detail_delivery_address)
    TextView detailDeliveryAddress;
    @InjectView(R.id.ft_ui_order_detail_delivery_time)
    TextView detailDeliveryTime;
    @InjectView(R.id.ft_ui_order_detail_limit_time)
    TextView detailLimitTime;
    @InjectView(R.id.ft_ui_order_detail_send_date)
    TextView detailSendDate;
    @InjectView(R.id.ft_ui_order_detail_line_desc)
    TextView detailLineDesc;
    @InjectView(R.id.ft_ui_order_detail_remark)
    TextView detailRemark;
    @InjectView(R.id.ft_ui_order_detail_btn_layout)
    LinearLayout detailBtnLayout;
    @InjectView(R.id.ft_ui_order_detail_btn_exception)
    TextView detailBtnException;
    @InjectView(R.id.ft_ui_order_detail_btn_opt)
    TextView detailBtnOpt;
    @InjectView(R.id.ft_ui_order_detail_record)
    TextView detailBtnRecord;
    @InjectView(R.id.ft_ui_order_detail_order_receive_time)
    TextView detailOrderReceiveTime;
    @InjectView(R.id.ft_ui_order_detail_order_receive_address)
    TextView detailOrderReceiveAddress;
    @InjectView(R.id.ft_ui_order_detail_order_receive_layout)
    LinearLayout detailOrderReceiveLayout;
    @InjectView(R.id.ft_ui_order_detail_start_sign_time)
    TextView detailStartSignTime;
    @InjectView(R.id.ft_ui_order_detail_start_sign_address)
    TextView detailStartSignAddress;
    @InjectView(R.id.ft_ui_order_detail_start_sign_layout)
    LinearLayout detailStartSignLayout;
    @InjectView(R.id.ft_ui_order_detail_start_picture_time)
    TextView detailStartPictureTime;
    @InjectView(R.id.ft_ui_order_detail_start_picture_arrow_layout)
    LinearLayout detailStartPictureArrowLayout;
    @InjectView(R.id.ft_ui_order_detail_start_pictures)
    MyGridView detailStartPictures;
    @InjectView(R.id.ft_ui_order_detail_start_picture_layout)
    LinearLayout detailStartPictureLayout;
    @InjectView(R.id.ft_ui_order_detail_abnormal_recyclerview)
    UltimateRecyclerView detailAbnormalRecyclerview;
    @InjectView(R.id.ft_ui_order_detail_abnormal_arrive_recyclerview)
    UltimateRecyclerView detailAbnormalArriveRecyclerview;
    @InjectView(R.id.ft_ui_order_detail_end_sign_time)
    TextView detailEndSignTime;
    @InjectView(R.id.ft_ui_order_detail_end_sign_address)
    TextView detailEndSignAddress;
    @InjectView(R.id.ft_ui_order_detail_end_sign_layout)
    LinearLayout detailEndSignLayout;
    @InjectView(R.id.ft_ui_order_detail_end_picture_time)
    TextView detailEndPictureTime;
    @InjectView(R.id.ft_ui_order_detail_end_picture_arrow_layout)
    LinearLayout detailEndPictureArrowLayout;
    @InjectView(R.id.ft_ui_order_detail_end_pictures)
    MyGridView detailEndPictures;
    @InjectView(R.id.ft_ui_order_detail_end_picture_layout)
    LinearLayout detailEndPictureLayout;
    @InjectView(R.id.ft_ui_order_detail_start_picture_arrow)
    ImageView detailStartPictureArrow;
    @InjectView(R.id.ft_ui_order_detail_end_picture_arrow)
    ImageView detailEndPictureArrow;
    @InjectView(R.id.ft_ui_order_detail_info)
    TextView detailInfo;

    @InjectView(R.id.ft_ui_order_detail_order_loc)
    TextView detailLocAddress;
    @InjectView(R.id.ft_ui_order_detail_order_wait)
    TextView detailWaitCnt;
    @InjectView(R.id.base_ui_title_open_loc_per)
    TextView detailOpenLoc;
    @InjectView(R.id.ft_ui_order_detail_merge_order_layout)
    LinearLayout detailMergeOrderLayout;
    @InjectView(R.id.ft_ui_order_detail_merge_order)
    TextView detailMergeOrder;

    LinearLayoutManager linearLayoutManager,linearLayoutManager2;
    String orderId;
    OrderEntity orderData,listOrderData;
    LocalOrderEntity localOrderEntity;
    List<OrderEntity> schedOrderList;//批量调度多单
    int status = 0;
    //1-待调度 2-待发车 3-已发车 4-已到达5-应到达 6-未识别7-已延期 0-手动标记异常，-1撤销（系统标记异常）
    // ,20出发签到，21出发拍照-已装车，30到达签到，40到达拍照-完成
    StatusEntity statusEntity;
    List<AbnormalEntity> abnormalList = new ArrayList<>();//发车及在途异常
    List<AbnormalEntity> abnormalArriveList = new ArrayList<>();//到达后异常
    AbnormalAdapter abnormalAdapter,abnormalArriveAdapter;
    int imageHeight = 0;
    int statusBarHeight = 0;
    int abnormalItemHeight, abnormalItemExpandHeight;
    LocationService locationService;
    ImageGridAdapter startAdapter, arriveAdapter;
    ArrayList<String> startImageList, arriveImageList;
    private ReceiveBroadcast receiveBroadcast;
    boolean isRefresh = true;

    private boolean hasLocation = true;
    private double distance;
    private PopupWindow myPopuwindiw;
    private PopupWindow youPopuwindow;
    private PopupWindow shePopuwindow;
    private PopupWindow hePopuwindow;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTaskTag(getClass().getSimpleName());
        setContentView(R.layout.ft_ui_order_detail);
        ButterKnife.inject(this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        getOrderId();
    }

    private void getOrderId() {
        try {
            if (null != getIntent()) {
                orderId = getIntent().getStringExtra(BaseConstant.INTENT_ID);
                listOrderData = (OrderEntity)getIntent().getSerializableExtra(BaseConstant.INTENT_CONTENT);
                OrderListResult orderListResult = (OrderListResult)getIntent().getSerializableExtra(BaseConstant.INTENT_ARG);
                if (orderListResult!=null){
                    schedOrderList = orderListResult.data;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void init() {
        BaseApplication.self().startOut();
        registerBroadcast();
        setBackLayoutVisibility(View.VISIBLE);
        setTitleText(getString(R.string.order_detail));
        setTitleTextVisibility(View.VISIBLE);
        detailOpenLoc.setVisibility(View.VISIBLE);

        refreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                getOrderDetail(false);
            }
        });
        detailMyScrollview.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                if (refreshLayout != null) {
                    refreshLayout.setEnabled(detailMyScrollview.getScrollY() == 0);
                }
            }
        });

        int screenWidth = OptionUtil.getScreenWidth(this);
        statusBarHeight = OptionUtil.getStatusBarHeight(this);
        if (statusBarHeight == 0) {
            statusBarHeight = DensityUtil.dip2px(this, 24);
        }
        imageHeight = (int) ((screenWidth - DensityUtil.dip2px(this, 50)) / 5);
        abnormalItemHeight = DensityUtil.dip2px(this, 41);
        abnormalItemExpandHeight = DensityUtil.dip2px(this, 111) + imageHeight;
        locationService = LocationService.getInstance(this);
        detailStartPictures.getLayoutParams().height = imageHeight;
        detailEndPictures.getLayoutParams().height = imageHeight;
        detailStartPictureArrow.setSelected(true);
        detailEndPictureArrow.setSelected(true);
        initUltimate();
        getOrderId();
        getOrderDetail(true);
//        new Handler().postDelayed(new Runnable(){
//            public void run() {
//                uploadTrack(true,orderId);
//            }
//        }, 5000);
        //localOrderEntity = SharedUtil.getLocalOrderEntity(BaseApplication.self());



    }

    @Override
    protected void onResume() {
        super.onResume();
        updateLocalOrder();

    }

    @Override
    protected void onDestroy() {
        try {
            if (myPopuwindiw!=null){
                myPopuwindiw.dismiss();
            }
            if (youPopuwindow!=null){
                youPopuwindow.dismiss();
            }
            if (shePopuwindow!=null){
                shePopuwindow.dismiss();
            }
            if (hePopuwindow!=null){
                hePopuwindow.dismiss();
            }
            unregisterReceiver(receiveBroadcast);
        } catch (Exception e) {
            e.printStackTrace();
        }
        super.onDestroy();
    }



    void updateInfo() {
        try {
            if (orderData != null) {
//                double disArrive = DistanceUtil.getDistance(new LatLng(Double.parseDouble(orderData.endPlace.lat), Double.parseDouble(orderData.endPlace.lon)),
//                        new LatLng(36.5094354394, 116.036554944));
//                LogUtil.e("disArrive= "+disArrive);
                orderData.schedId = listOrderData.schedId;
                abnormalAdapter.setImage_prefix(orderData.image_prefix);
                statusEntity = OptionUtil.getOrderStatus(this, orderData);
                LogUtil.e("statusEntity.status= " + statusEntity.status);
//                statusEntity.status = 3;
                status = statusEntity.status;
                detailStatus.setText(statusEntity.name);
                if (statusEntity.status == OptionUtil.ORDER_STATUS_1 || statusEntity.status ==
                        OptionUtil.ORDER_STATUS_2 || statusEntity.status == OptionUtil.ORDER_STATUS_20
                        || statusEntity.status == OptionUtil.ORDER_STATUS_21 || statusEntity.status
                        == OptionUtil.ORDER_STATUS_3 || statusEntity.status == OptionUtil
                        .ORDER_STATUS_30
                        || statusEntity.status == OptionUtil.ORDER_STATUS_4|| statusEntity.status == OptionUtil.ORDER_STATUS_41) {
                    detailStatus.setTextColor(getResources().getColor(R.color.button_red));
                } else {
                    detailStatus.setTextColor(getResources().getColor(R.color.button_green));
                }
                String id = String.format(getString(R.string.order_id), orderData.orderNum);
                detailOrderId.setText(id);
                if (orderData.startPlace != null) {
                    detailStartAddress.setText(orderData.startPlace.address);
                }
                if (orderData.endPlace != null) {
                    detailDeliveryAddress.setText(orderData.endPlace.address);
                }
                if (!StringUtil.isEmpty(listOrderData.mergeOrderNum)){
                    detailMergeOrderLayout.setVisibility(View.VISIBLE);
                    detailMergeOrder.setText(listOrderData.mergeOrderNum);
                }else {
                    detailMergeOrderLayout.setVisibility(View.GONE);
                }
                detailDeliveryTime.setText(TimeUtil.formatGLWZTime(orderData.estimateBeginDate));
                detailLimitTime.setText(TimeUtil.formatGLWZTime(orderData.arriveDate));
                detailSendDate.setText(TimeUtil.formatGLWZTime(orderData.sendDate));
                detailLineDesc.setText(orderData.lineDesc);
                detailRemark.setText(orderData.remark);
                detailInfo.setVisibility(View.GONE);
                if (orderData.orderReceive != null) {
                    if (!StringUtil.isEmpty(orderData.orderReceive.operateTime)) {
                        detailInfo.setVisibility(View.VISIBLE);
                        detailOrderReceiveLayout.setVisibility(View.VISIBLE);
                        detailOrderReceiveTime.setText(TimeUtil.formatGLWZTime(orderData.orderReceive
                                .operateTime));
                        detailOrderReceiveAddress.setText(orderData.orderReceive.address);
                    } else {
                        detailOrderReceiveLayout.setVisibility(View.GONE);
                    }

                } else {
                    detailOrderReceiveLayout.setVisibility(View.GONE);
                }
                if (orderData.signStart != null) {
                    if (!StringUtil.isEmpty(orderData.signStart.operateTime)) {
                        detailInfo.setVisibility(View.VISIBLE);
                        detailStartSignLayout.setVisibility(View.VISIBLE);
                        detailStartSignTime.setText(TimeUtil.formatGLWZTime(orderData.signStart
                                .operateTime));
                        detailStartSignAddress.setText(orderData.signStart.address);
                    } else {
                        detailStartSignLayout.setVisibility(View.GONE);
                    }

                } else {
                    detailStartSignLayout.setVisibility(View.GONE);
                }
                if (orderData.startImage != null) {
                    if (!StringUtil.isEmpty(orderData.startImage.operateTime)) {
                        detailInfo.setVisibility(View.VISIBLE);
                        detailStartPictureLayout.setVisibility(View.VISIBLE);
                        detailStartPictureTime.setText(TimeUtil.formatGLWZTime(orderData
                                .startImage.operateTime));
                        startImageList = OptionUtil.formatImagesString(
                                orderData.startImage.imageList, orderData.image_prefix);
                        startAdapter = new ImageGridAdapter(this, startImageList, imageHeight);
                        detailStartPictures.setAdapter(startAdapter);
                        detailStartPictures.setOnItemClickListener(new AdapterView
                                .OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view,
                                                    int position, long id) {
                                myPopuwindiw =showImagePreview(startImageList, position);
                            }
                        });
                    } else {
                        detailStartPictureLayout.setVisibility(View.GONE);
                    }
                } else {
                    detailStartPictureLayout.setVisibility(View.GONE);
                }
                if (orderData.signEnd != null) {
                    if (!StringUtil.isEmpty(orderData.signEnd.operateTime)) {
                        detailInfo.setVisibility(View.VISIBLE);
                        detailEndSignLayout.setVisibility(View.VISIBLE);
                        detailEndSignTime.setText(TimeUtil.formatGLWZTime(orderData.signEnd
                                .operateTime));
                        detailEndSignAddress.setText(orderData.signEnd.address);
                    } else {
                        detailEndSignLayout.setVisibility(View.GONE);
                    }
                } else {
                    detailEndSignLayout.setVisibility(View.GONE);
                }
                if (orderData.arriveImage != null) {
                    if (!StringUtil.isEmpty(orderData.arriveImage.operateTime)) {
                        detailInfo.setVisibility(View.VISIBLE);
                        detailEndPictureLayout.setVisibility(View.VISIBLE);
                        detailEndPictureTime.setText(TimeUtil.formatGLWZTime(orderData
                                .arriveImage.operateTime));
                        arriveImageList = OptionUtil.formatImagesString(
                                orderData.arriveImage.imageList, orderData.image_prefix);
                        arriveAdapter = new ImageGridAdapter(this, arriveImageList, imageHeight);
                        detailEndPictures.setAdapter(arriveAdapter);
                        detailEndPictures.setOnItemClickListener(
                                new AdapterView.OnItemClickListener() {
                                    @Override
                                    public void onItemClick(AdapterView<?> parent, View view,
                                                            int position, long id) {
                                        youPopuwindow =showImagePreview(arriveImageList, position);
                                    }
                                });
                    } else {
                        detailEndPictureLayout.setVisibility(View.GONE);
                    }
                } else {
                    detailEndPictureLayout.setVisibility(View.GONE);
                }
                /*if (orderData.abnormalList != null && orderData.abnormalList.size() > 0) {
                    detailInfo.setVisibility(View.VISIBLE);
                    detailAbnormalRecyclerview.setVisibility(View.VISIBLE);
                    abnormalList.clear();

                    abnormalList.addAll(orderData.abnormalList);
                    Collections.reverse(abnormalList);

                    abnormalAdapter.notifyDataSetChanged();
                    calcAbnormalViewTotalHeight();
                } else {
                    detailAbnormalRecyclerview.setVisibility(View.GONE);
                }*/
                if (orderData.abnormalList != null && orderData.abnormalList.size() > 0) {
                    abnormalList.clear();
                    abnormalArriveList.clear();
                    for (int i=0;i<orderData.abnormalList.size();i++){
                        AbnormalEntity abnormalEntity = orderData.abnormalList.get(i);
                        if (orderData.arriveImage!=null&&!StringUtil.isEmpty(orderData.arriveImage.operateTime)){
                            if (abnormalEntity.operateTime.compareTo(orderData.arriveImage.operateTime)>0){
                                abnormalArriveList.add(abnormalEntity);
                            }else {
                                abnormalList.add(abnormalEntity);
                            }
                        }else {
                            abnormalList.add(abnormalEntity);
                        }
                    }
                    if (abnormalList.size()>0){
                        detailAbnormalRecyclerview.setVisibility(View.VISIBLE);
                    }else {
                        detailAbnormalRecyclerview.setVisibility(View.GONE);
                    }
                    if (abnormalArriveList.size()>0){
                        detailAbnormalArriveRecyclerview.setVisibility(View.VISIBLE);
                    }else {
                        detailAbnormalArriveRecyclerview.setVisibility(View.GONE);
                    }
                    calcAbnormalViewTotalHeight();
                    abnormalAdapter.notifyDataSetChanged();
                    abnormalArriveAdapter.notifyDataSetChanged();
                }else {
                    detailAbnormalRecyclerview.setVisibility(View.GONE);
                    detailAbnormalArriveRecyclerview.setVisibility(View.GONE);
                }

                detailBtnLayout.setVisibility(View.VISIBLE);
                detailBtnException.setVisibility(View.GONE);
                detailBtnOpt.setVisibility(View.GONE);
                detailTipLayout.setVisibility(View.GONE);
                setButtonRecordVisibility(orderData.status,false);
                switch (status) {
                    case OptionUtil.ORDER_STATUS_1:
                        detailBtnOpt.setVisibility(View.VISIBLE);
                        detailBtnOpt.setText(getString(R.string.order_status_55));
                        setButtonRecordVisibility(orderData.status, true);
                        break;
                    case OptionUtil.ORDER_STATUS_2:
                        detailBtnOpt.setVisibility(View.VISIBLE);
                        detailBtnOpt.setText(getString(R.string.order_status_8));
                        break;
                    case OptionUtil.ORDER_STATUS_20:
                        //detailBtnException.setVisibility(View.VISIBLE);
                        detailBtnOpt.setVisibility(View.VISIBLE);
                        detailBtnOpt.setText(getString(R.string.order_status_start));
                        detailTipLayout.setVisibility(View.VISIBLE);
                        setButtonRecordVisibility(orderData.status, true);
                        break;
                    case OptionUtil.ORDER_STATUS_21:
                        //detailBtnException.setVisibility(View.VISIBLE);
                        detailTipLayout.setVisibility(View.VISIBLE);
                        setButtonRecordVisibility(orderData.status, true);
                        break;
                    case OptionUtil.ORDER_STATUS_3:
                        //detailBtnException.setVisibility(View.VISIBLE);
                        detailBtnOpt.setVisibility(View.VISIBLE);
                        detailBtnOpt.setText(getString(R.string.order_status_9));
                        detailTipLayout.setVisibility(View.VISIBLE);
                        setButtonRecordVisibility(orderData.status, true);
                        break;
                    case OptionUtil.ORDER_STATUS_30:
                        //detailBtnException.setVisibility(View.VISIBLE);
                        if (orderData.signEnd!=null&&orderData.signEnd.operateTime!=null){
                            long signEndTime = Long.parseLong(TimeUtil.tranFormatTime(TimeUtil.formatGLWZTime(orderData.signEnd.operateTime),"yyyy-MM-dd HH:mm:ss"));
                            if ((System.currentTimeMillis() - signEndTime) <604800000){
                                detailBtnOpt.setVisibility(View.VISIBLE);
                                detailBtnOpt.setText(getString(R.string.order_status_complete));
                                detailTipLayout.setVisibility(View.VISIBLE);
                                setButtonRecordVisibility(orderData.status,true);
                            }
                        }
                        break;
                    case OptionUtil.ORDER_STATUS_4:
                        //detailBtnException.setVisibility(View.VISIBLE);
                        detailBtnOpt.setVisibility(View.VISIBLE);
                        detailBtnOpt.setText(getString(R.string.order_status_9));
                        detailTipLayout.setVisibility(View.GONE);
                        break;
                    case OptionUtil.ORDER_STATUS_40:
                        detailBtnException.setVisibility(View.VISIBLE);
                        break;
                    case OptionUtil.ORDER_STATUS_41:
                        if (orderData.signEnd!=null&&orderData.signEnd.operateTime!=null){
                            long signEndTime = Long.parseLong(TimeUtil.tranFormatTime(TimeUtil.formatGLWZTime(orderData.signEnd.operateTime),"yyyy-MM-dd HH:mm:ss"));
                            if ((System.currentTimeMillis() - signEndTime) <604800000){
                                detailBtnOpt.setVisibility(View.VISIBLE);
                                detailBtnOpt.setText(getString(R.string.order_status_complete));
                            }
                        }
                        //detailBtnException.setVisibility(View.VISIBLE);

                        break;
                    default:
                        detailBtnLayout.setVisibility(View.GONE);
                        break;
                }

                if (null != detailMyScrollview) {
                    detailMyScrollview.scrollTo(0, 0);
                    detailMyScrollview.smoothScrollTo(0,0);
                }
                if (status == OptionUtil.ORDER_STATUS_2) {
                    OptionUtil.isGpsOpen(OrderDetailActivity.this, titleText);
//                    int res = BaseApplication.self().location(BaseApplication.LOCTIME);
//                    if (res==0){
//                        //启动定位成功
//                        OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.track_bd_loc_success));
//                    }else {
//                        OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.track_bd_loc_fail));
//                    }
                    hasLocation = false;
                } else if (status == OptionUtil.ORDER_STATUS_20 || status == OptionUtil
                        .ORDER_STATUS_21 || status == OptionUtil.ORDER_STATUS_3 || status ==
                        OptionUtil.ORDER_STATUS_30) {
                    //定位中 不作处理
                } else {
                    //停止定位
//                    BaseApplication.self().stopOut();
                }
                updateLocalOrder();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void updateLocalOrder(){
        localOrderEntity = OrderUtil.getLocalOrder(this, listOrderData);
    }

    private void setButtonRecordVisibility(int status,boolean isVisible){
        if (isVisible){
            if (status==2||status==3){
                detailBtnRecord.setVisibility(View.VISIBLE);
            }
        }else {
            detailBtnRecord.setVisibility(View.GONE);
        }
    }

    private void initUltimate() {
        linearLayoutManager = new LinearLayoutManager(this);
        detailAbnormalRecyclerview.setLayoutManager(linearLayoutManager);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        abnormalAdapter = new AbnormalAdapter(this, abnormalList, imageHeight, "");
        detailAbnormalRecyclerview.setAdapter(abnormalAdapter);
        detailAbnormalRecyclerview.enableLoadmore(false);
        detailAbnormalRecyclerview.enableSwipeRefresh(false);
        detailAbnormalRecyclerview.endFinish(true);
        abnormalAdapter.setiOnAbnormalListener(new IOnAbnormalListener() {
            @Override
            public void onExpand(int position) {
                if (abnormalList.get(position).isExpanded) {
                    abnormalList.get(position).isExpanded = false;
                } else {
                    abnormalList.get(position).isExpanded = true;
                }
                abnormalAdapter.notifyDataSetChanged();
                calcAbnormalViewTotalHeight();
            }

            @Override
            public void onImagePreview(int position, int index) {

               shePopuwindow =showImagePreview(OptionUtil.formatImagesString(
                        abnormalList.get(position).imageList, orderData.image_prefix), index);
            }
        });

        linearLayoutManager2 = new LinearLayoutManager(this);
        detailAbnormalArriveRecyclerview.setLayoutManager(linearLayoutManager2);
        linearLayoutManager2.setOrientation(LinearLayoutManager.VERTICAL);
        abnormalArriveAdapter = new AbnormalAdapter(this, abnormalArriveList, imageHeight, "");
        detailAbnormalArriveRecyclerview.setAdapter(abnormalArriveAdapter);
        detailAbnormalArriveRecyclerview.enableLoadmore(false);
        detailAbnormalArriveRecyclerview.enableSwipeRefresh(false);
        detailAbnormalArriveRecyclerview.endFinish(true);
        abnormalArriveAdapter.setiOnAbnormalListener(new IOnAbnormalListener() {
            @Override
            public void onExpand(int position) {
                if (abnormalArriveList.get(position).isExpanded) {
                    abnormalArriveList.get(position).isExpanded = false;
                } else {
                    abnormalArriveList.get(position).isExpanded = true;
                }
                abnormalArriveAdapter.notifyDataSetChanged();
                calcAbnormalViewTotalHeight();
            }

            @Override
            public void onImagePreview(int position, int index) {
                hePopuwindow =showImagePreview(OptionUtil.formatImagesString(
                        abnormalArriveList.get(position).imageList, orderData.image_prefix), index);
            }
        });
    }

    /**
     * 计算异常列表的高度并设置
     * 收起时高：41dp,展开时高110+imageHeight
     */
    void calcAbnormalViewTotalHeight() {
        int totalHeight = 0;
        int totalHeight2 = 0;
        if (abnormalList != null && abnormalList.size() > 0) {
            for (AbnormalEntity abnormalEntity : abnormalList) {
                if (abnormalEntity.isExpanded) {
                    totalHeight = totalHeight + abnormalItemExpandHeight;
                } else {
                    totalHeight = totalHeight + abnormalItemHeight;
                }
            }
            detailAbnormalRecyclerview.getLayoutParams().height = totalHeight;
            if (isRefresh) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        detailMyScrollview.fullScroll(ScrollView.FOCUS_UP);
                        detailMyScrollview.scrollTo(0, 0);
                        isRefresh = false;
                    }
                });
            }
        }else {
            detailAbnormalRecyclerview.setVisibility(View.GONE);
        }
        if (abnormalArriveList != null && abnormalArriveList.size() > 0) {
            for (AbnormalEntity abnormalEntity : abnormalArriveList) {
                if (abnormalEntity.isExpanded) {
                    totalHeight2 = totalHeight2 + abnormalItemExpandHeight;
                } else {
                    totalHeight2 = totalHeight2 + abnormalItemHeight;
                }
            }
            detailAbnormalArriveRecyclerview.getLayoutParams().height = totalHeight2;
            if (isRefresh) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        detailMyScrollview.fullScroll(ScrollView.FOCUS_UP);
                        detailMyScrollview.scrollTo(0, 0);
                        isRefresh = false;
                    }
                });
            }
        }else {
            detailAbnormalArriveRecyclerview.setVisibility(View.GONE);
        }
    }

    PopupWindow showImagePreview(ArrayList<String> imageList, int index) {
        ImagesPreviewUtil imagesPreviewUtil = new ImagesPreviewUtil(this, imageList, titleText);
        imagesPreviewUtil.setShowDelete(false);
        imagesPreviewUtil.setStatusBarHeight(statusBarHeight);
        PopupWindow popupWindow=imagesPreviewUtil.showImagesPreview(index);
        return popupWindow;
    }

    @OnClick({R.id.ft_ui_order_detail_btn_exception, R.id.ft_ui_order_detail_btn_opt, R.id.ft_ui_order_detail_start_picture_arrow_layout,
            R.id.ft_ui_order_detail_end_picture_arrow_layout,R.id.base_ui_title_open_loc_per,R.id.ft_ui_order_detail_record})
    public void onClick(View view) {
        Bundle bundle;
        Intent intent;
        switch (view.getId()) {
            case R.id.ft_ui_order_detail_btn_exception:
                bundle = new Bundle();
                bundle.putString(BaseConstant.INTENT_ID, orderId);
                intent = new Intent(this, UploadAbnormalActivity.class);
                intent.putExtras(bundle);
                startActivity(intent);
                break;
            case R.id.ft_ui_order_detail_btn_opt:
                switch (status) {
                    case OptionUtil.ORDER_STATUS_1:
                        //接单
                        if (hasLocation) {
                            if (distance>50000){
                                Toast.makeText(BaseApplication.self(), "接单距离起运点不得超过50公里", Toast
                                        .LENGTH_LONG).show();
                                return;
                            }
                            orderReceive(true);
                        } else {
                            Toast.makeText(OrderDetailActivity.this, getString(R.string.loc), Toast
                                    .LENGTH_LONG).show();
                        }
                        break;
                    case OptionUtil.ORDER_STATUS_2:
                        //出发签到
                        if (hasLocation) {
                            signForOrder(true, 0);
                        } else {
                            Toast.makeText(OrderDetailActivity.this, getString(R.string.loc), Toast
                                    .LENGTH_LONG).show();
                        }
                        break;
                    case OptionUtil.ORDER_STATUS_20:
                        //跳转到出发拍照
                        bundle = new Bundle();
                        bundle.putString(BaseConstant.INTENT_ID, orderId);
                        bundle.putInt(BaseConstant.INTENT_TYPE, BaseConstant
                                .UPLOAD_IMAGE_TYPE_START);
                        intent = new Intent(this, UploadImageActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                        break;
                    case OptionUtil.ORDER_STATUS_3:
                        //到达签到
                        uploadTrack(true, orderId);
                        break;
                    case OptionUtil.ORDER_STATUS_30:
                        //跳转到到达拍照
                        bundle = new Bundle();
                        bundle.putString(BaseConstant.INTENT_ID, orderId);
                        bundle.putInt(BaseConstant.INTENT_TYPE, BaseConstant
                                .UPLOAD_IMAGE_TYPE_ARRIVE);
                        intent = new Intent(this, UploadImageActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                        break;
                    case OptionUtil.ORDER_STATUS_4:
                        //到达签到
                        uploadTrack(true, orderId);
                        break;
                    case OptionUtil.ORDER_STATUS_41:
                        //跳转到到达拍照
                        bundle = new Bundle();
                        bundle.putString(BaseConstant.INTENT_ID, orderId);
                        bundle.putInt(BaseConstant.INTENT_TYPE, BaseConstant
                                .UPLOAD_IMAGE_TYPE_ARRIVE);
                        intent = new Intent(this, UploadImageActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                        break;
                }
                break;
            case R.id.ft_ui_order_detail_start_picture_arrow_layout:
                if (detailStartPictures.getVisibility() == View.VISIBLE) {
                    detailStartPictureArrow.setSelected(false);
                    detailStartPictures.setVisibility(View.GONE);
                } else {
                    detailStartPictureArrow.setSelected(true);
                    detailStartPictures.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.ft_ui_order_detail_end_picture_arrow_layout:
                if (detailEndPictures.getVisibility() == View.VISIBLE) {
                    detailEndPictureArrow.setSelected(false);
                    detailEndPictures.setVisibility(View.GONE);
                } else {
                    detailEndPictureArrow.setSelected(true);
                    detailEndPictures.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.base_ui_title_open_loc_per:
                if (BaseConstant.IS_KEEP_LIVE){
                    IntentWrapper.whiteListMatters(this, "轨迹跟踪服务的持续运行");
                }
                OptionUtil.setting(OrderDetailActivity.this);
//                signForOrder2(true,4);
                break;
            case R.id.ft_ui_order_detail_record:
//                if (BaseConstant.IS_KEEP_LIVE){
//                    IntentWrapper.whiteListMatters(this, "轨迹跟踪服务的持续运行");
//                }
                if (localOrderEntity==null){
//                    orderData.schedId = listOrderData.schedId;
                    OrderUtil.startLocation(OrderDetailActivity.this,titleText,orderData,schedOrderList);
//                    OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.tip13));
                }else {
                    int res = BaseApplication.self().location(BaseApplication.LOCTIME);
                    if (res==0){
                        //启动定位成功
                        OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.track_bd_loc_success));
                    }else {
                        OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.track_bd_loc_fail));
                    }
                }
                break;
        }
    }

    /**
     * 获取运单详情
     *
     * @param showLoad
     */
    void getOrderDetail(boolean showLoad) {
        Map<String, Object> argMap = HttpUtil.getEncryMap(this);
        argMap.put("orderId", orderId);
        ShowLoadTask task = new ShowLoadTask(this, taskTag, containLayout, loadLayout, getString
                (R.string.task2),
                showLoad, retryListener, BaseConstant.GET_ORDER_DETAIL, argMap, TaskConstant.POST);
        task.setParseClass(OrderDetailResult.class);
        task.setiOnResultListener(new IOnResultListener() {

            @Override
            public void onOK(DispatchTask task) {
                isRefresh = true;
                OrderDetailResult res = (OrderDetailResult) task.resultEntity;
                orderData = res.data;
                GPSEntity gpsEntity = LocationUtil.gcj_To_Gps84(Double.parseDouble(SharedUtil.getLat(BaseApplication.self())), Double.parseDouble(SharedUtil.getLng(BaseApplication.self())));
                double wgLat = gpsEntity.getWgLat();
                double wgLon = gpsEntity.getWgLon();
                if (orderData!=null) {
                    if (orderData.startPlace!=null) {
                        distance = DistanceUtil.getDistance(new LatLng(Double.parseDouble(orderData.startPlace.lat), Double.parseDouble(orderData.startPlace.lon)),
                                new LatLng(wgLat, wgLon));
                    }
                }
                updateInfo();
            }

            @Override
            public void onError(DispatchTask task) {


            }

            @Override
            public void onDone(DispatchTask task) {
                if (refreshLayout.isRefreshing()) {
                    refreshLayout.setRefreshing(false);
                }
            }
        });
        task.execute();
    }

    IOnTryClickListener retryListener = new IOnTryClickListener() {
        @Override
        public void onTry() {
            getOrderDetail(true);
        }

        @Override
        public void onOption() {

        }
    };

    /**
     * 接单
     *
     * @param showDialog
     */
    private void orderReceive(boolean showDialog) {
        final Map<String, Object> argMap = HttpUtil.getEncryMap(this);
        argMap.put("tel", SharedUtil.getTel(this));
        argMap.put("orderId", orderId);
        argMap.put("lat", SharedUtil.getLat(this));
        argMap.put("lon", SharedUtil.getLng(this));
        argMap.put("address", SharedUtil.getAddress(this));

        //TODO 判断50公里提示

        ShowDialogTask task = new ShowDialogTask(this, taskTag, titleText, getString(R.string
                .task3), showDialog, BaseConstant.ORDER_RECEIVE, argMap, TaskConstant.POST);
        task.setiOnResultListener(new IOnResultListener() {
            @Override
            public void onOK(DispatchTask task) {
                OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.tip24));
                try {
                    if (BaseConstant.LOGING)
                        FileUtil.writeFile(BaseConstant.LOGPATH, "\n时间："+TimeUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss")+" 接单提交记录成功：经度=" +argMap.get("lon")+" 纬度=" +argMap.get("lat")+" orderId=" +argMap.get("orderId"), true);
                }catch (Exception e){
                    e.printStackTrace();
                }
                BroadcastUtil.sendOrderRefreshBroadcast(OrderDetailActivity.this);
                getOrderDetail(true);
            }

            @Override
            public void onError(DispatchTask task) {

            }

            @Override
            public void onDone(DispatchTask task) {

            }
        });
        task.execute();
    }

    /**
     * 签到
     *
     * @param showDialog
     * @param type       类型：0是出发、1是到达
     */
    private void signForOrder(boolean showDialog, final int type) {
        final Map<String, Object> argMap = HttpUtil.getEncryMap(this);
        argMap.put("tel", SharedUtil.getTel(this));
        argMap.put("orderId", orderId);
        if (type == 0) {
            argMap.put("type", "1");
            argMap.put("lat", SharedUtil.getLat(this));
            argMap.put("lon", SharedUtil.getLng(this));
            argMap.put("address", SharedUtil.getAddress(this));
        } else {
            argMap.put("type", "4");
            argMap.put("auto", "0");

            OrderEntity order = null;
            if (localOrderEntity!=null){
                if (localOrderEntity.schedOrderList!=null){
                    for (OrderEntity orderEntity:localOrderEntity.schedOrderList){
                        if (orderEntity.id.equals(orderData.id)){
                            order = orderEntity;
                        }
                    }
                }else {
                    order = localOrderEntity.order;
                }
            }
//            if ((order!=null&&order.isArrivedAndOut)||orderData.status==OptionUtil.ORDER_STATUS_4){
//                //到终点圈然后出圈 采用目标地址的经纬度116.401578,39.903973
//                //平台设为已到达后，app可以到达签到，采用目标地址的经纬度116.40143,39.904309
////                LogUtil.e("localOrderData.isArrivedAndOut="+localOrderData.isArrivedAndOut);
//                if (orderData.endPlace!=null&&StringUtil.isEmpty(orderData.endPlace.lat)){
//                    OptionUtil.addToast(this,"终点坐标缺失");
//                    return;
//                }
//                double lat = Double.parseDouble(orderData.endPlace.lat)+0.001;
//                double lng = Double.parseDouble(orderData.endPlace.lon)+0.001;
//                String strLat = String.valueOf(lat);
//                String strLon = String.valueOf(lng);
//                if (strLat.length()>13){
//                    strLat = strLat.substring(0,13);
//                }
//                if (strLon.length()>13){
//                    strLon = strLon.substring(0,13);
//                }
//                argMap.put("lat", ""+strLat);
//                argMap.put("lon", ""+strLon);
//                if (orderData.endPlace!=null)
//                    argMap.put("address", orderData.endPlace.address);
//            }else {
                //到达签到采用轨迹最后一个点
                List<LocationEntity> locationEntityList = locationService.queryByOrderId(listOrderData.schedId,false);
                if (locationEntityList!=null&&locationEntityList.size()>0){
                    long ct = System.currentTimeMillis();
                    long lt = Long.parseLong(locationEntityList.get(0).getCreate_time());
                    //if ((ct-lt)>600000){
                      //  OptionUtil.addToast(OrderDetailActivity.this,"最后定位点在10分钟之前，正在重新定位，预计需要1分钟");
                      //  return;
                   // }
                    argMap.put("lat", locationEntityList.get(0).getLat());
                    argMap.put("lon", locationEntityList.get(0).getLng());
                    argMap.put("address", locationEntityList.get(0).getAddress());
                }else {
                    argMap.put("lat", ""+SharedUtil.getLat(this));
                    argMap.put("lon", ""+SharedUtil.getLng(this));
                    argMap.put("address", ""+SharedUtil.getAddress(this));
                }
            }

//        }
        ShowDialogTask task = new ShowDialogTask(this, taskTag, titleText, getString(R.string
                .task3), showDialog, BaseConstant.ORDER_SIGN, argMap, TaskConstant.POST);
        task.setiOnResultListener(new IOnResultListener() {
            @Override
            public void onOK(DispatchTask task) {
                if (type == 0) {
                    OptionUtil.addToast(OrderDetailActivity.this, getString(R.string.tip12));
                    OrderUtil.startLocation(OrderDetailActivity.this,titleText,orderData,schedOrderList);
                    if (BaseConstant.LOGING)
                        FileUtil.writeFile(BaseConstant.LOGPATH, "\n时间：" + TimeUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss") + " 提货签到提交记录成功：经度=" + argMap.get("lon") + " 纬度=" + argMap.get("lat") + " orderId=" + argMap.get("orderId"), true);
                } else {
                    try {
                        BaseApplication.self().dealArrivedSign(orderData);
                        /*if (localOrderEntity!=null){
                            if (localOrderEntity.schedOrderList==null){
                                if (localOrderEntity.order.id.equals(orderData.id)){
                                    BaseApplication.self().stopOut(false);
                                }
                            }else {
                                if (localOrderEntity.schedOrderList.size()<=1){
                                    if (localOrderEntity.order.schedId.equals(orderData.schedId)){
                                        BaseApplication.self().stopOut(false);
                                    }
                                }else {
                                    boolean canStop = true;
                                    for (OrderEntity orderEntity:localOrderEntity.schedOrderList){
                                        if (orderData.id.equals(orderEntity.id)){
                                            orderEntity.isArrivedSign = true;
                                        }else {
                                            if (orderEntity.signEnd!=null&&!StringUtil.isEmpty(orderEntity.signEnd.operateTime)){

                                            }else {
                                                if (!orderEntity.isArrivedSign){
                                                    canStop = false;
                                                }
                                            }
                                        }
                                    }
                                    SharedUtil.saveLocalOrder(OrderDetailActivity.this, localOrderEntity);
                                    if (canStop){
                                        BaseApplication.self().stopOut(false);
                                    }
                                }
                            }
                        }*/
                        if (BaseConstant.LOGING)
                            FileUtil.writeFile(BaseConstant.LOGPATH, "\n时间："+TimeUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss")+" 手动到达签到提交记录成功：经度=" +argMap.get("lon")+" 纬度=" +argMap.get("lat")+" orderId=" +argMap.get("orderId"), true);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    //清空临时图片
                    DataCleanManager.cleanCustomCache(OrderDetailActivity.this, BaseConstant
                            .IMAGETAMPPATH);
                }
                BroadcastUtil.sendOrderRefreshBroadcast(OrderDetailActivity.this);
                getOrderDetail(true);
            }

            @Override
            public void onError(DispatchTask task) {

            }

            @Override
            public void onDone(DispatchTask task) {

            }
        });
        task.execute();
    }

    /**
     * 上传轨迹
     *
     * @param showDialog
     * @param orderId
     */
    private void uploadTrack(boolean showDialog, String orderId) {
        final List<LocationEntity> list = locationService.queryByOrderId(listOrderData.schedId);
        String latLng = "";//38.66545224,116.2541254, 2016-11-24 10:06:45,中国北京市海淀区丰秀中路
        for (LocationEntity locationEntity : list) {
            String item = locationEntity.lat + "," + locationEntity.lng + "," + TimeUtil
                    .formatServiceTime2(locationEntity.update_time) + "," + locationEntity.address;
            if (StringUtil.isEmpty(latLng)) {
                latLng = item;
            } else {
                latLng = latLng + "#" + item;
            }
            locationEntity.setIsUploaded("1");
        }
        if (StringUtil.isEmpty(latLng)) {
            SharedUtil.saveOrderTimer(OrderDetailActivity.this, System.currentTimeMillis());
            signForOrder(true, 1);
            return;
        }
        Map<String, Object> argMap = HttpUtil.getEncryMap(this);
        argMap.put("tel", SharedUtil.getTel(this));
        argMap.put("orderId", orderId);
        argMap.put("latLon", latLng);
        ShowDialogTask task = new ShowDialogTask(this, taskTag, titleText, getString(R.string
                .task3), showDialog, BaseConstant.UPLOAD_LATLNG, argMap, TaskConstant.POST);
        task.setShowTipSuccess(true);
        task.setiOnResultListener(new IOnResultListener() {
            @Override
            public void onOK(DispatchTask task) {
                locationService.update2Uploaded(list);
                SharedUtil.saveOrderTimer(OrderDetailActivity.this, System.currentTimeMillis());
                signForOrder(true, 1);
            }

            @Override
            public void onError(DispatchTask task) {

            }

            @Override
            public void onDone(DispatchTask task) {

            }
        });
        task.execute();
    }

    private void registerBroadcast() {
        if (receiveBroadcast == null) {
            receiveBroadcast = new ReceiveBroadcast();
            IntentFilter filter = new IntentFilter();
            filter.addAction(BaseConstant.ACTION_ORDER_REFRESH);
            filter.addAction(BaseConstant.ACTION_LOCATION_LOC);
            registerReceiver(receiveBroadcast, filter);
        }
    }

    public class ReceiveBroadcast extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            try {
                String action = intent.getAction();
                if (action.equals(BaseConstant.ACTION_ORDER_REFRESH)) {
                    getOrderDetail(true);
                } else if (action.equals(BaseConstant.ACTION_LOCATION_LOC)) {
                    hasLocation = true;
                    detailLocAddress.setText(SharedUtil.getAddress(OrderDetailActivity.this));
                    List<LocationEntity> list = locationService.queryByOrderId(listOrderData.schedId);
                    if (list!=null){
                        detailWaitCnt.setText(""+list.size()+"条待上传");
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }

}
